package com.haoxin.ai_course.modules.course.controller.admin;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.haoxin.ai_course.common.annotation.SysLog;
import com.haoxin.ai_course.common.base.AbstractController;
import com.haoxin.ai_course.common.utils.R;
import com.haoxin.ai_course.modules.course.entity.AcTopicAnswerResult;
import com.haoxin.ai_course.modules.course.service.AcTopicAnswerResultService;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;



/**
 * 答题结果表
 * 
 * @author xingxiangguo
 * @email bugcn@qq.com
 * @date 2022-06-06 09:44:49
 */
@RestController
@AllArgsConstructor
@RequestMapping("/course/actopicanswerresult")
@Api(value="api",tags="后台-对话框题目回答结果统计管理")
public class AdminAcTopicAnswerResultController  extends AbstractController {
    private final  AcTopicAnswerResultService acTopicAnswerResultService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("course:actopicanswerresult:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        QueryWrapper<AcTopicAnswerResult> queryWrapper = new QueryWrapper<>();
        IPage<AcTopicAnswerResult> sysConfigList = acTopicAnswerResultService.page(mpPageConvert.<AcTopicAnswerResult>pageParamConvert(params),queryWrapper);
        return R.ok().put("page", mpPageConvert.pageValueConvert(sysConfigList));
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("course:actopicanswerresult:info")
    public R info(@PathVariable("id") Integer id){
        return R.ok().put("acTopicAnswerResult", acTopicAnswerResultService.getById(id));
    }


    /**
     * 新增答题结果表
     */
    @SysLog("新增答题结果表数据")
    @RequestMapping("/save")
    @RequiresPermissions("course:actopicanswerresult:save")
    public R save(@RequestBody AcTopicAnswerResult acTopicAnswerResult){
        acTopicAnswerResultService.save(acTopicAnswerResult);
        return R.ok();
    }


    /**
     * 修改
     */
    @SysLog("修改答题结果表数据")
    @RequestMapping("/update")
    @RequiresPermissions("course:actopicanswerresult:update")
    public R update(@RequestBody AcTopicAnswerResult acTopicAnswerResult){
		acTopicAnswerResultService.updateById(acTopicAnswerResult);
        return R.ok();
    }


    /**
     * 删除
     */
    @SysLog("删除答题结果表数据")
    @RequestMapping("/delete")
    @RequiresPermissions("course:actopicanswerresult:delete")
    public R delete(@RequestBody Integer[] ids){
		acTopicAnswerResultService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
	
}
